<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>{{ list.length }}</strong></span>
    <ul @click="changeSel" class="filters">
      <li>
        <a 
        @click="isSel = 'all'" 
        :class="{ selected: isSel === 'all' }" href="javascript:;" >全部</a>
      </li>
      <li>
        <a 
        @click="isSel = 'no'" 
        :class="{ selected: isSel === 'no' }"  href="javascript:;">未完成</a>
      </li>
      <li>
        <a 
        @click="isSel = 'yes'" 
        :class="{ selected: isSel === 'yes' }"  href="javascript:;" >已完成</a>
      </li>
    </ul>
    <button @click="clearClick" class="clear-completed" >清除已完成</button>
  </footer>
</template>

<script>
export default {
  props: ['list'],
  data() {
    return {
      // 1. 定义状态 isAll 取值范围是 all / yes / no
      isSel: 'all'
    }
  },
  methods: {
    changeSel() {
      // console.log(this.isSel)
      // 当 a 标签被点击时就是恰当的时机
      this.$emit('changeTask', this.isSel)
    },
    clearClick() {
      this.$emit('clearDone')
    }
  }
}
</script>